package com.bluepixel.tvitalia;

import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;

public class Utils {

    public static final String XML_TAG="XML";
    public static final String PLAYLIST_TAG="PLAYLIST";
    public static final int LOADING_MSG_MILLS=3000;

    // public static final String
    // ONLINE_BASE_URL="http://dl.dropboxusercontent.com/u/12706770/FilmGratis/WEBTVITA/";
    public static final String ONLINE_BASE_URL="http://www.villenoire.net/FilmGratis/WEBTVITA/";
    public static final String ONLINE_ANDROID_BASE_URL=ONLINE_BASE_URL + "android/";
    public static final String ONLINE_CAT_LIST_FILENAME="tv_categories_2.xml";

    public static final String CONST_IMG_PREFIX=ONLINE_BASE_URL + "icons/channels/";
    public static final int[] LOADING_MSGS=new int[]{R.string.loading01, R.string.loading02, R.string.loading03,
	R.string.loading04, R.string.loading05 };

    public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) {
	Bitmap output=Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
	Canvas canvas=new Canvas(output);

	final int color=0xff424242;
	final Paint paint=new Paint();
	final Rect rect=new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
	final RectF rectF=new RectF(rect);
	final float roundPx=pixels;

	paint.setAntiAlias(true);
	canvas.drawARGB(0, 0, 0, 0);
	paint.setColor(color);
	canvas.drawRoundRect(rectF, roundPx, roundPx, paint);

	paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
	canvas.drawBitmap(bitmap, rect, rect, paint);

	return Bitmap.createScaledBitmap(output, 200, 200, false);
    }
}